
import { get_localbrand, set_localbrand } from "@/utils/Routerinfo"
const initInfo = [
    {
        path: "/dashbord",
        name: "Dashbord",
        component: () => import("@/views/dashbord"),
        meta: { title: "首页", icon: "el-icon-eleme" }
    }
]

const state = {
    brandRoute: get_localbrand() || initInfo,
    routeIndex: 0
}

const mutations = {
    set_brandRoute(state, payload) {
        if (typeof payload == "object") {
            if (payload.name != "Dashbord") {
                let index = state.brandRoute.findIndex(route => route.name == payload.name);
                if (index == -1) {
                    state.brandRoute.push(payload)
                    set_localbrand(state.brandRoute)
                }
            }
        } else {
            state.brandRoute = initInfo
        }
    },
    remove_brandRoute(state, { index, route }) {
        if (route.name != "Dashbord") {
            state.brandRoute.splice(index, 1)
            set_localbrand(state.brandRoute)
        }
    },
    clear_brandRoute(state) {
        state.brandRoute = initInfo
    }
}

export default {
    namespaced: true,
    state,
    mutations
}